<extend name="Base/common"/>
<block name="body">
	<div class="span9 page_message">
		<section id="contents">
			<include file="Addons/_nav"/>
			<div class="table-bar">
				<div class="fl">
					<div class="tools"><a href="javascript:void(0);" class="btn setting_group">设置用户组</a> &nbsp; <a
							href="{:U ( 'Home/AuthGroup/export' )}" class="btn">导出用户</a> &nbsp;
						<if condition="$syc_wechat"><a href="{:U('syc_auth_group')}" class="btn tongbu">一键同步微信公众号粉丝</a>
							&nbsp;</if>
					</div>
				</div>
				<!-- 高级搜索 -->
				<div class="search-form fr cf">
					<div class="sleft" style="margin-right:10px;">
						<select name="group" style="border:none; padding:4px; margin:0;">
							<option value="{:addons_url('UserCenter://UserCenter/lists',array('group_id'=>0))}"
							<eq name="$group_id" value="0">selected</eq>
							>全部用户</option>
							<volist name="auth_group" id="vo">
								<option value="{:addons_url('UserCenter://UserCenter/lists',array('group_id'=>$vo['id']))}"
								<eq name="vo['id']" value="$group_id">selected</eq>
								>{$vo.title}</option>
							</volist>
						</select>
					</div>
					<div class="sleft">
						<input type="text" placeholder="请输入关键字" value="{:I('nickname')}" class="search-input"
						       name="nickname">
						<a url="{:addons_url('UserCenter://UserCenter/lists',$get_param)}" id="search"
						   href="javascript:;" class="sch-btn"><i class="btn-search"></i></a></div>
				</div>
				<!-- 多维过滤 -->
			</div>
			<!-- 数据列表 -->
			<div class="data-table">
				<div class="table-striped">
					<table cellspacing="1">
						<!-- 表头 -->
						<thead>
						<tr>
							<th class="row-selected row-selected"><input type="checkbox"
							                                             class="check-all regular-checkbox"
							                                             id="checkAll">
								<label for="checkAll"></label></th>
							<th>头像</th>
							<th>用户昵称</th>
							<th>性别</th>
							<th>分组</th>
							<th>OpenID</th>
							<th>操作</th>
						</tr>
						</thead>

						<!-- 列表 -->
						<tbody>
						<volist name="list_data" id="vo">
							<tr>
								<td><input type="checkbox" id="check_{$vo.uid}" name="ids[]" value="{$vo.uid}"
								           class="ids regular-checkbox">
									<label for="check_{$vo.uid}"></label></td>
								<td>{$vo.headimgurl|url_img_html}</td>
								<td>{$vo.nickname}</td>
								<td>{$vo.sex_name}</td>
								<td>{$vo.group}</td>
								<td>{$vo.openid}</td>
								<td><a href="{:addons_url('UserCenter://UserCenter/detail',array('uid'=>$vo[uid]))}"
								       target="_self">详细资料</a>
									<!--<a href="{:addons_url('UserCenter://UserCenter/edit',array('uid'=>$vo[uid]))}" target="_self">编辑</a>-->
									<a href="{:U('Home/CreditData/lists',array('uid'=>$vo[uid]))}"
									   target="_self">积分记录</a>
								</td>
							</tr>
						</volist>
						</tbody>
					</table>
				</div>
			</div>
			<div class="page"> {$_page|default=''}</div>
		</section>
	</div>
	<!-- 用户分组弹框 -->
	<div class="group_html" style="display:none">
		<div class="manage_group normal_dialog">
			<div class="content">
				<!--            <select name="type" id="select_type" style="width:25%">
									<option value="0">移入</option>
									<option value="1">移出</option>
							</select>-->
				<select name="group" id="select_group" style="width:100%">
					<volist name="auth_group" id="vo">
						<option value="{$vo.id}">{$vo.title}</option>
					</volist>
				</select>

				<div class="btn_wrap">
					<button class="btn setting_group" url="{:U('changeGroup')}" target-form="ids">确定</button>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="script">
	<script type="text/javascript">
		$(function () {
			//搜索功能
			$("#search").click(function () {
				var url = $(this).attr('url');
				var query = $('.search-form').find('input').serialize();
				query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
				query = query.replace(/^&/g, '');
				if (url.indexOf('?') > 0) {
					url += '&' + query;
				} else {
					url += '?' + query;
				}
				if (query == '') {
					url = "{:addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/lists')}";
				}
				window.location.href = url;
			});

			//回车自动提交
			$('.search-form').find('input').keyup(function (event) {
				if (event.keyCode === 13) {
					$("#search").click();
				}
			});
			$('select[name=group]').change(function () {
				location.href = this.value;
			});
			//设置分组
			$('.setting_group').click(function () {
				var html = $($('.group_html').html());
				query = $('.ids').serialize();
				if (query == "") {
					alert('请选择用户');
					return;
				}
				$.Dialog.open('设置用户分组', {width: 300, height: 160}, html);
				//$.thinkbox(html);
				$('button', html).click(function () {
					that = this;
					target = $(that).attr('url');
					query = query + "&group_id=" + $('#select_group', html).val();//+ "&type="+$('#select_type', html).val();
					$(that).addClass('disabled').attr('autocomplete', 'off').prop('disabled', true);
					$.post(target, query).success(function (data) {
						location.reload();
						$('.thinkbox-modal-blackout-default,.thinkbox-default').hide();
					});
				})
			})

			//同步用户组数据到微信端

		})
	</script>
</block>
